package nicepc;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;
import nicepc.pojo.User;
import nicepc.tools.kafka.Sender;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;


@SpringBootApplication
@Slf4j
public class SpringbootApplication implements CommandLineRunner {
    public static void main(String[] args) {
        SpringApplication.run(SpringbootApplication.class, args);
    }

//    @Autowired
//    private Sender sender;

    @Autowired
    RedisTemplate redisTemplate;

    @Override
    public void run(String... args) throws Exception {
        ObjectMapper objectMapper = new ObjectMapper();

//        User user = new User(1, "peng", "receive");
//        ValueOperations ops = redisTemplate.opsForValue();
//        String s = objectMapper.writeValueAsString(user);
//        ops.set("s", s);

//        JSONObject jsonObject = JSONObject.fromObject(s);

//        User user1 = (User) JSONObject.toBean(jsonObject, User.class);
//        String s1 = user1.getName();
//        sender.send(s);
    }
}
